<?php

//严格类型检查模式
declare(strict_types=1);

namespace app\api\controller;


use app\api\validate\User;
use app\BaseController;

class Sms extends BaseController
{
    public function code(): object //返回对象
    {

        //接收前端发送过来的手机号码
        $phoneNumber = input('param.phone_number', '', 'trim');
        //  $phoneNumber=111;
        $data = [
            'phone_number' => $phoneNumber,
        ];

        //验证电话号码
        $validate = new User();
        if (!$validate->scene('send_code')->check($data)) {
            return show(config("status.error"), $validate->getError());
        }
        //调用business层数据
        if (\app\common\business\Sms::sendCode($phoneNumber, 6,"Ali")) {
            return show(config("status.success"), "发送验证码成功");
        }

        return show(config("status.error"), "发送验证码失败");
    }



}